﻿@{
    ViewBag.Title = "RptBuyRank";
}
@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/gridlayout.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/export.js")" type="text/javascript"></script>
}
<body>
    <form id="form1" runat="server" method="post" style="height: 100%">

        @Html.Partial("~/Views/Modular/ReportsToolbar.cshtml")

        <div id="DivHeader">
            <table style="margin-bottom:4px;">
                <tr>
                    <td width="70px" align="right">单据日期：</td>
                    <td width="310px">
                        @Html.Partial("~/Views/Modular/dxDateRange.cshtml")
                    </td>
                    <td width="70px" align="right">排序方式：</td>
                    <td width="200px">
                        <input id="comOrderby" name="comOrderby" class="mini-combobox" style="width:198px;"
                               showNullItem="false" allowInput="false" align="left" data="Orderby" />
                    </td>
                </tr>
                <tr>
                    <td width="70px" align="right">商户名称：</td>
                    <td width="310px">
                        @Html.Partial("~/Views/Modular/LookupCorpInfo.cshtml")
                    </td>
                    <td width="70px" align="right">门店名称：</td>
                    <td width="200px">
                        @Html.Partial("~/Views/Modular/LookupStockInfo.cshtml")
                    </td>
                </tr>
            </table>
        </div>
        <div class="mini-fit">
            <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" borderStyle="border:1;" pageSize="15"
                 url="../Report/GetCommonReport"
                 allowCellSelect="true" allowCellEdit="true" showSummaryRow="true" ondrawsummarycell="onDrawSummaryCell"
                 fitColumns="false">
                <div property="columns">
                    <div type="checkcolumn"></div>
                    <div field="FNumber" width="110" headerAlign="center">会员编码</div>
                    <div field="FName" width="200" headerAlign="center">会员名称</div>
                    <div field="FPhone" width="200" headerAlign="center">联系电话</div>
                    <div field="FQty" name="FQty" width="100" headerAlign="center" align="right" numberFormat="#,0.00">购买数量</div>
                    <div field="FRealAmount" name="FRealAmount" width="100" headerAlign="center" align="right" numberFormat="#,0.00">消费金额</div>
@*                    <div field="FPoint" name="FPoint" width="100" headerAlign="center" align="right" numberFormat="#,0.00">消费积分</div>
                    <div field="FStockName" name="FStockName" width="120" headerAlign="center" >门店名称</div>*@
                </div>
            </div>
        </div>

        <script type="text/javascript">

            var Orderby = [{ "id": "0", "text": "按金额降序" },
                         { "id": "1", "text": "按金额升降" },
                         { "id": "2", "text": "按数量降序" },
                         { "id": "3", "text": "按数量升序" }]

        mini.parse();
        var form = new mini.Form("form1");
        var grid = mini.get("datagrid1");
        var uID = parent.window.getSystemAppID();
        var sumFields = "FQty,FRealAmount,FPoint";

        function FormShown() {
            var nowDate = new Date();
            mini.getbyName("FDate1").setValue(nowDate);
            mini.getbyName("FDate2").setValue(nowDate);
            mini.getbyName("comOrderby").select(0);
            LoadData();
        }

        function clearloca() {
            mini.getbyName("FStockID").setValue("");
            mini.getbyName("FStockID").setText("");
            mini.getbyName("FStockName").setValue("");
            mini.getbyName("FCorpItemID").setValue("");
            mini.getbyName("FCorpItemID").setText("");
            mini.getbyName("FCorpName").setValue("");
            var nowDate = new Date();
            mini.getbyName("FDate1").setValue(nowDate);
            mini.getbyName("FDate2").setValue(nowDate);
            mini.getbyName("comdatasel").setValue(0);
            mini.getbyName("comOrderby").setValue(0);
        }

        function LoadData() {
            var cDate1 = mini.getbyName("FDate1").getFormValue();
            var cDate2 = mini.getbyName("FDate2").getFormValue();
            var mStockID = mini.getbyName("FStockID").getValue();
            var mCorpID = mini.getbyName("FCorpItemID").getValue();
            var mDataType = mini.getbyName("comOrderby").getValue();

            var json = "[{";
            json = json + '"mReportType":' + '"6001",';//列表类型
            json = json + '"mSystemAppID":' + '"' + uID + '",';
            json = json + '"mDate1":' + '"' + cDate1 + '",';
            json = json + '"mDate2":' + '"' + cDate2 + '",';
            json = json + '"mStockID":' + '"' + mStockID + '",';
            json = json + '"mFCorpID":' + '"' + mCorpID + '",';
            json = json + '"mDataType":' + '"' + mDataType + '"';
            json = json + "}]";

            grid.load({ mydata: json });

            mExportDataUrl = grid.url;
            mExportDataJson = json;//导出
        }

        function printdata() {
            var url = "../Report/PrintReport";
            mini.open({
                url: url,
                title: "打印", width: 1000, height: 700,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var NoneDisplayCol = [0];
                    iframe.contentWindow.InitalPrint(grid, NoneDisplayCol, parent.window.getSystemCompany() + "会员消费排行表");
                }
            });
        }

        </script>

    </form>
</body>